#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "teacherLogin.h"
#include "studentLogin.h"
#include <iostream>
using namespace std;
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setWindowIcon(QIcon(":/img/home.png"));
    this->teacherLogin = new TeacherLogin();
    this->studentLogin = new StudentLogin();
    this->intro = new Introduction();
    connect(studentLogin->sls,SIGNAL(back2main()),this,SLOT(reshow()));
    connect(teacherLogin->tls,SIGNAL(back2main()),this,SLOT(reshow()));
    connect(intro ,SIGNAL(back2main()),this,SLOT(reshow()));
}

MainWindow::~MainWindow()
{
    delete ui;
}
void MainWindow::reshow()
{
    cout << "reshow main" << endl;
    this->show();
}

void MainWindow::on_teacherLogin_clicked()
{
    cout << "enter teacher login ui" << endl;
    this->hide();
    connect(teacherLogin,SIGNAL(back2main()),this,SLOT(reshow()));
    teacherLogin->show();
}

void MainWindow::on_studentLogin_clicked()
{
    cout << "enter student login ui" << endl;
    this->hide();
    connect(studentLogin, SIGNAL(back2main()), this, SLOT(reshow()));
    studentLogin->show();
}

void MainWindow::on_introduction_clicked()
{
    this->hide();
    this->intro->show();
}
